package com.crazy.common;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;

/**
 * @author panyonghui
 * @describe 配置文件获取
 * @date 2022/1/19 11:49
 */
@Configuration
public class MessageSourceConfiguration {
    @Value("${resource.message.path}")
    private String resourcePath;
    @Value("${resource.message.defaultEncoding}")
    private String defaultEncoding;

    @Bean(name="messageSource")
    public ReloadableResourceBundleMessageSource messageSource(){
        ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSourc = new ReloadableResourceBundleMessageSource();
        reloadableResourceBundleMessageSourc.setBasenames(resourcePath.split(","));
        reloadableResourceBundleMessageSourc.setDefaultEncoding(defaultEncoding);
        return reloadableResourceBundleMessageSourc;
    }


}
